package com.wswy.wzcx.ui.main.ad

import android.content.Context
import android.os.Bundle
import android.support.v7.app.AppCompatDialog
import android.text.TextUtils
import android.view.ViewGroup
import com.blankj.utilcode.util.SizeUtils
import com.facebook.drawee.view.SimpleDraweeView
import com.wswy.wzcx.R
import com.wswy.wzcx.model.home.RouterUtils
import kotlinx.android.synthetic.main.dialog_interaction_ad.*

class InteractioDialog(context: Context,private val adItemVo: AdItemVo) : AppCompatDialog(context, R.style.customTransparentDialog2) {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContentView(R.layout.dialog_interaction_ad)


        (adItemVo.adView as? SimpleDraweeView)?.setImageURI(adItemVo.adModel.imgUrl)

        ll_content.addView(adItemVo.adView,0,ViewGroup.LayoutParams(SizeUtils.dp2px(375f),SizeUtils.dp2px(480f)))

        img_close.setOnClickListener {

            dismiss()
        }

        adItemVo.adView.setOnClickListener {
            if (!TextUtils.isEmpty(adItemVo.adModel.linkUrl)) {
                RouterUtils
                        .startTarget(context, adItemVo.adModel.linkTarget, adItemVo.adModel.linkUrl)
            }
            dismiss()
        }

    }

}